package com.fds.system.config;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import lombok.extern.slf4j.Slf4j;

/**
 * @author: fds
 * @date: 2019/7/22
 * @description: controller统一异常拦截
 */
@Slf4j
@ControllerAdvice
public class ControllerAop {

    /**
     * 拦截系统未知异常
     * 
     * @param req HttpServletRequest
     * @param e
     * @return
     */
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public String defaultErrorHandler(HttpServletRequest req, Exception e) {
        log.error("接口：" + req.getRequestURI() + ";异常：" + e.getMessage(), e);
        return "系统错误";
    }
}
